<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="姓名" prop="studentName">
        <el-input
          v-model="queryParams.studentName"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="校区" prop="studentSchool">
        <el-select v-model="queryParams.studentSchool" placeholder="请选择校区" clearable>
          <el-option
            v-for="dict in dict.type.stu_class_address"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="学生状态" prop="studentState">
        <el-select v-model="queryParams.studentState" placeholder="请选择学生状态" clearable>
          <el-option
            v-for="dict in dict.type.stu_student_state"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="模拟面试" prop="studentInterview">
        <el-select v-model="queryParams.studentInterview" placeholder="请选择模拟面试" clearable>
          <el-option
            v-for="dict in dict.type.stu_student_interview"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="结业考试" prop="studentTest">
        <el-select v-model="queryParams.studentTest" placeholder="请选择结业考试" clearable>
          <el-option
            v-for="dict in dict.type.stu_student_test"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="电话" prop="studentPhone">
        <el-input
          v-model="queryParams.studentPhone"
          placeholder="请输入电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="年龄" prop="studentAge">
        <el-input
          v-model="queryParams.studentAge"
          placeholder="请输入年龄"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['student:student:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['student:student:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['student:student:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleUpdates"
          v-hasPermi="['student:student:edit']"
        >状态修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-refresh"
          size="mini"
          :disabled="single"
          @click="handleChangeClass"
          v-hasPermi="['student:student:edit']"
        >转班</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-plus"
          size="mini"
          :disabled="single"
          @click="handleTrack"
          v-hasPermi="['student:student:edit']"
        >添加追踪</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="fileOpen"
          v-hasPermi="['student:student:export']"
        >导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['student:student:export']"
        >导出</el-button>
      </el-col>

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="studentList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="id" />
      <el-table-column label="姓名" align="center" prop="studentName" />
      <el-table-column  label="班级" align="center" prop="stuclass.className">
        <template slot-scope="scope">
          <el-select v-model="scope.row.studentClass"
                     :options="classes"
                     @change="changeForm(scope.row)"
                     :value="scope.row.studentClass">
            <el-option
              v-for="item in classes"
              :label="item.className"
              :value="item.id"
              :key="item.id"
            ></el-option>
          </el-select>
        </template>
      </el-table-column >
      <el-table-column  label="校区" align="center" prop="studentSchool">
        <template slot-scope="scope">
          <el-select v-model="scope.row.studentSchool"
                     :options="dict.type.stu_class_address"
                     @change="changeForm(scope.row)"
                     :value="scope.row.studentSchool">
            <el-option
              v-for="dict in dict.type.stu_class_address"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </template>
      </el-table-column >
      <el-table-column  label="学生状态" align="center" prop="studentState">
        <template slot-scope="scope">
          <el-select v-model="scope.row.studentState"
                     :options="dict.type.stu_student_state"
                     @change="changeForm(scope.row)"
                     :value="scope.row.studentState">
            <el-option
              v-for="dict in dict.type.stu_student_state"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </template>
      </el-table-column >
      <el-table-column  label="模拟面试" align="center" prop="studentInterview">
        <template slot-scope="scope">
          <el-select v-model="scope.row.studentInterview"
                     :options="dict.type.stu_student_interview"
                     @change="changeForm(scope.row)"
                     :value="scope.row.studentInterview">
            <el-option
              v-for="dict in dict.type.stu_student_interview"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </template>
      </el-table-column >
      <el-table-column  label="结业考试" align="center" prop="studentTest">
        <template slot-scope="scope">
          <el-select v-model="scope.row.studentTest"
                     :options="dict.type.stu_student_test"
                     @change="changeForm(scope.row)"
                     :value="scope.row.studentTest">
            <el-option
              v-for="dict in dict.type.stu_student_test"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </template>
      </el-table-column >
      <el-table-column label="电话" align="center" prop="studentPhone" />
      <el-table-column label="年龄" align="center" prop="studentAge" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="300px">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-location"
            @click="handleTrackRecord(scope.row)"
            v-hasPermi="['student:student:edit']"
          >追踪</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-star-on"
            @click="handleAttention(scope.row)"
            v-hasPermi="['student:student:edit']"
          >关注</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['student:student:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['student:student:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        :data="{updateSupport:upload.updateSupport}"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的下井次数设置数据
          <el-link
            type="info"
            style="font-size:12px"
            @click="downloadTemplate('xjszTemplate.xlsx')"
          >下载模板</el-link>
        </div>
        <div
          class="el-upload__tip"
          style="color:red"
          slot="tip"
        >提示：仅允许导入“xls”或“xlsx”格式文件！是否全勤中：1代表全勤，0代表固定次数，不得有空值！！</div>
      </el-upload>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加关注对话框 -->
    <el-dialog :title="title" :visible.sync="attentionOpen" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="姓名" prop="studentName">
          <el-input v-model="form.studentName" placeholder="请输入姓名" :disabled='true' :style="{width: '100%'}" />
        </el-form-item>
        <el-form-item label="负责老师" prop="studentTeacher">
          <el-select v-model="form.studentTeacher" placeholder="请选择负责老师">
            <el-option
              v-for="dict in dict.type.stu_teachers"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="困难状态" prop="state">
          <el-select v-model="form.state" placeholder="请选择困难状态">
            <el-option
              v-for="dict in dict.type.stu_difficulty_state"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="attentionForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 追踪按钮对话框 -->
    <el-dialog :title="title" :visible.sync="trackRecordOpen" width="500px" append-to-body>
      <el-timeline>
        <el-timeline-item v-for="(item,index) in stuTrackList"  :timestamp="item.startTime" :color="index==stuTrackList.length-1?'red':'#0bbd87'"  placement="top">
          <el-card>
            <h4>跟踪人: [{{item.studentName}}]</h4>
            <p>情况说明: {{item.problemText}}</p>
          </el-card>
        </el-timeline-item>

      </el-timeline>
    </el-dialog>
    <!-- 添加追踪对话框 -->
    <el-dialog :title="title" :visible.sync="trackOpen" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <!--<el-form-item label="跟踪学生id" prop="studentId">
          <el-input v-model="form.studentId" placeholder="请输入跟踪学生id" />
        </el-form-item>-->
        <!--<el-form-item label="学生姓名" prop="studentName">
          <el-input v-model="form.studentName" placeholder="请输入学生姓名" />
        </el-form-item>-->
        <el-form-item label="问题类型" prop="problemType">
          <el-select v-model="form.problemType" placeholder="请选择问题类型">
            <el-option
              v-for="dict in dict.type.stu_problem_type"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="发生时间" prop="startTime">
          <el-date-picker clearable
           v-model="form.startTime"
           type="date"
           value-format="yyyy-MM-dd"
           placeholder="请选择发生时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="扣除分数" prop="einMinus">
          <el-input v-model="form.einMinus" placeholder="请输入扣除分数" />
        </el-form-item>
        <!--<el-form-item label="总分" prop="insgesamt">
          <el-input v-model="form.insgesamt" placeholder="请输入总分" />
        </el-form-item>-->
        <el-form-item label="问题描述" prop="problemText">
          <el-input v-model="form.problemText" type="textarea" placeholder="请输入问题描述" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="trackSubmitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!--留级转班对话框-->
    <el-dialog :title="title" :visible.sync="changeOpen" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="姓名" prop="changeStudentName">
          <el-input v-model="form.studentName"  placeholder="请输入姓名" :disabled='true' :style="{width: '100%'}" />
        </el-form-item>
        <el-form-item label="转入班级">
          <el-select v-model="form.studentClass" placeholder="请选择班级">
            <el-option v-for="item in classes"
                       :label="item.className"
                       :value="item.id"
                       :key="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="学状状态" prop="changeStudentState">
          <el-select v-model="form.studentState" placeholder="请选择学状状态" :disabled='true' :style="{width: '100%'}" >
            <el-option
              v-for="dict in dict.type.stu_student_state"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="changeClass">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!--状态修改对话框-->
    <el-dialog :title="title" :visible.sync="amendOpen" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="学生状态" prop="studentState">
          <el-select v-model="form.studentState" placeholder="请选择学生状态">
            <el-option
              v-for="dict in dict.type.stu_student_state"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="模拟面试" prop="studentInterview">
          <el-select v-model="form.studentInterview" placeholder="请选择模拟面试">
            <el-option
              v-for="dict in dict.type.stu_student_interview"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结业考试" prop="studentTest">
          <el-select v-model="form.studentTest" placeholder="请选择结业考试">
            <el-option
              v-for="dict in dict.type.stu_student_test"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="amendSubmitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改学生表对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="姓名" prop="studentName">
          <el-input v-model="form.studentName" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="班级">
          <el-select v-model="form.studentClass" placeholder="请选择班级">
            <el-option v-for="item in classes"
                       :label="item.className"
                       :value="item.id"
                       :key="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="校区" prop="studentSchool">
          <el-select v-model="form.studentSchool" placeholder="请选择校区">
            <el-option
              v-for="dict in dict.type.stu_class_address"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="学生状态" prop="studentState">
          <el-select v-model="form.studentState" placeholder="请选择学生状态">
            <el-option
              v-for="dict in dict.type.stu_student_state"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="模拟面试" prop="studentInterview">
          <el-select v-model="form.studentInterview" placeholder="请选择模拟面试">
            <el-option
              v-for="dict in dict.type.stu_student_interview"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结业考试" prop="studentTest">
          <el-select v-model="form.studentTest" placeholder="请选择结业考试">
            <el-option
              v-for="dict in dict.type.stu_student_test"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="电话" prop="studentPhone">
          <el-input v-model="form.studentPhone" placeholder="请输入电话" />
        </el-form-item>
        <el-form-item label="年龄" prop="studentAge">
          <el-input v-model="form.studentAge" placeholder="请输入年龄" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listStudent, getStudent, delStudent, addStudent, updateStudent ,getListClasses,updateStudents,Upload} from "@/api/student/student";
import { listChangeClass, getChangeClass, delChangeClass, addChangeClass, updateChangeClass } from "@/api/student/changeClass";
import { listTrack, getTrack, delTrack, addTrack, updateTrack,listTrackByStuID } from "@/api/student/track";
import { listAttention, getAttention, delAttention, addAttention, updateAttention } from "@/api/student/attention";
import { getToken } from "@/utils/auth";
export default {
  name: "Student",
  dicts: ['stu_student_interview', 'stu_student_test', 'stu_student_state', 'stu_class_address','stu_problem_type','stu_teachers', 'stu_difficulty_state'],
  data() {
    return {
      // 导入参数
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/student/student/importData",
      },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 修改状态框是否显示
      amendOpen: false,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 学生表表格数据
      studentList: [],
      //学生追踪记录数据
      stuTrackList:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      changeOpen: false,
      trackOpen: false,
      trackRecordOpen: false,
      attentionOpen: false,
      //查询所有班级
      classes: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        studentName: null,
        studentClass: null,
        studentSchool: null,
        studentState: null,
        studentInterview: null,
        studentTest: null,
        studentPhone: null,
        studentAge: null,
        problemType: null
      },
      // 表单参数
      form: {

      },
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //表格展示改变
    changeForm(row){
      updateStudent(row).then(response => {
        this.$modal.msgSuccess("修改成功");
        this.getList();
      });
    },
    //导出按钮
    fileOpen(){
      this.upload.open=true;
    },
    //导入提交按钮
    submitFileForm() {
      this.$refs.upload.submit();
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /**导入*/
    handleUpload(file){
      Upload(file).then(response => {
        this.$modal.msgSuccess("添加成功");
        this.getList();
      });
    },
    /** 查询学生表列表 */
    getList() {
      this.loading = true;
      listStudent(this.queryParams).then(response => {
        this.studentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        studentName: null,
        studentClass: null,
        studentSchool: null,
        studentState: null,
        studentInterview: null,
        studentTest: null,
        studentPhone: null,
        studentAge: null,
        ids:[],
        problemType: null,
        startTime: null,
        einMinus: null,
        problemText: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.getClasses();
      this.reset();
      this.open = true;
      this.title = "添加学生表";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.getClasses();
      this.reset();
      const id = row.id || this.ids
      getStudent(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改学生表";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateStudent(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addStudent(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 追踪按钮操作 */
    handleTrackRecord(row){
      const stuid = row.id || this.ids
      listTrackByStuID(stuid).then(response => {
        this.stuTrackList= response.rows;
        this.trackRecordOpen= true;
        this.title ="["+row.studentName+ "] 的跟踪历史";
      });
    },
    /** 新增追踪按钮操作 */
    handleTrack(row) {
      this.reset();
      const id = row.id || this.ids
      getStudent(id).then(response => {
        this.form = response.data
        this.trackOpen = true;
        this.title = this.form.studentName+" 添加问题跟踪记录";
      });
    },
    /** 新增追踪提交按钮 */
    trackSubmitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          addTrack(this.form).then(response => {
            this.$modal.msgSuccess("添加追踪成功");
            this.trackOpen = false;
            this.getList();
          });
        }
      });
    },
    /** 新增关注按钮操作 */
    handleAttention(row) {
      this.reset();
      const id = row.id || this.ids
      getStudent(id).then(response => {
        this.form = response.data
        this.attentionOpen = true;
        this.title = this.form.studentName+" 加入重点关注";
      });
    },
    /** 新增关注提交按钮 */
    attentionForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          addAttention(this.form).then(response => {
            this.$modal.msgSuccess("加入重点关注成功");
            this.attentionOpen = false;
            this.getList();
          });
        }
      });
    },

    /** 转班按钮操作 */
    handleChangeClass(row){
      this.getClasses();
      this.reset();
      const id = row.id || this.ids
      getStudent(id).then(response => {
        this.form = response.data;
        this.form.studentState=4;
        this.changeOpen = true;
        this.title = this.form.studentName +"转班处理";
      });
    },
    /** 转班提交按钮 */
    changeClass() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          addChangeClass(this.form).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.changeOpen = false;
            this.getList();
          });
        }
      });
    },

    /** 修改状态按钮操作 */
    handleUpdates(row) {
      this.reset();
      const ids = row.id || this.ids
      this.form.ids=ids;
      this.amendOpen = true;
      this.title = "选中"+ids.length+"数据";
    },
    /** 状态提交按钮 */
    amendSubmitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          updateStudents(this.form).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.amendOpen = false;
            this.getList();
          });
        }
      });
    },



    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除学生表编号为"' + ids + '"的数据项？').then(function() {
        return delStudent(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('student/student/export', {
        ...this.queryParams
      }, `student_${new Date().getTime()}.xlsx`)
    },
    /**查询所有班级*/
    getClasses() {
      getListClasses(null).then(res => {
        this.classes=res.rows;
      });
    }
  },
  mounted() {
    this.getClasses();
  }
};
</script>



